<template>
  <div class="container">
    <div class="list">
      <div
        v-for="(indicator, key) in indicators1"
        :key="key"
        class="item"
        :class="{ active: indicator.active }"
        @click="toggleIndicator(key)"
      >
        <div>
          <StatusIndicator
            :statusValue="indicator.active"
            :label="indicator.label"
            :activeClassPrefix="indicator.activeClassPrefix"
          />
        </div>
      </div>
    </div>
    <div class="divider"></div>
    <div class="list">
      <div
        v-for="(indicator, key) in indicators2"
        :key="key"
        class="item"
        :class="{ active: indicator.active }"
        @click="toggleIndicator(key)"
      >
        <div>
          <StatusIndicator
            :statusValue="indicator.active"
            :label="indicator.label"
            :activeClassPrefix="indicator.activeClassPrefix"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import StatusIndicator from "./StatusIndicator.vue";
export default {
  props: {},
  components: {
    StatusIndicator,
  },
  data() {
    return {
      indicators1: [
        { label: "自检指示", active: true },
        { label: "通信发送", active: false },
        { label: "通信接收", active: false },
        {
          label: "声光故障",
          active: true,
          activeClassPrefix: "active-circle-yellow",
        },
        { label: "备用", active: true },
        { label: "备用", active: false },
        { label: "备用", active: false },
        { label: "备用", active: false },
        { label: "备用", active: true },
        { label: "备用", active: false },
        { label: "备用", active: false },
      ],
      indicators2: [
        { label: "主电", active: true },
        { label: "备电", active: false },
        { label: "火灾报警", active: false },
        {
          label: "故障报警",
          active: true,
          activeClassPrefix: "active-circle-yellow",
        },
        { label: "消音", active: true },
        {
          label: "系统故障",
          active: true,
          activeClassPrefix: "active-circle-yellow",
        },
        { label: "备用", active: false },
        { label: "备用", active: false },
        { label: "备用", active: false },
        { label: "备用", active: true },
        { label: "备用", active: false },
      ],
    };
  },
  methods: {
    toggleIndicator(key) {
      const newState = !this.indicators[key].active;
      this.$emit("indicator-change", {
        id: key,
        active: newState,
      });
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  .list {
    height: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    // align-items: center;
    justify-content: space-between;
    // flex-wrap: wrap;

    .item {
      flex: 1;
      min-height: 0;
      //   height: calc(100% / 11);
      //   background: pink;
      //   min-height: 100px;
      //   width: 49%;
      //   background: pink;
      display: flex;
      justify-content: center;
      align-items: center;
      //   &:nth-child(odd) {
      //     border-right: 3px solid #43403d;
      //   }
    }
  }
}

.divider {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background-color: #4d4946;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}
</style>